home *** CD-ROM | disk | FTP | other *** search
- /*
- File: StorageDriverHeader.c
-
- Contains: All globally exported functions and structures
-
- Version: 2.0
-
- Copyright: © 1998-1999 by Apple Computer, Inc., all rights reserved.
-
- */
-
-
-
- #include <Types.h>
- #include <Devices.h>
- #include <DriverServices.h>
- #include <USB.h>
-
- #include "StorageClassDriver.h"
- #include "USB_Version.h"
- #include "StorageDeviceConfiguration.h"
-
- //------------------------------------------------------
- //
- // Protos
- //
- //------------------------------------------------------
- static OSStatus StorageDriverValidateHW(USBDeviceRef device, USBDeviceDescriptor *desc);
- static OSStatus StorageDriverInitDevice(USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable);
- static OSStatus StorageDriverInitInterface( UInt32 interfaceNum, USBInterfaceDescriptor *interfaceDesc, USBDeviceDescriptor *deviceDesc, USBDeviceRef device);
- static OSStatus StorageDriverFinalize(USBDeviceRef device, USBDeviceDescriptorPtr desc );
- static OSStatus StorageDriverNotifyProc(UInt32 notification, void *pointer, UInt32 refcon);
-
- //------------------------------------------------------
- //
- // This is the driver description structure that the expert looks for first.
- // If it's here, the information within is used to match the driver
- // to the device whose descriptor was passed to the expert.
- // Information in this block is also used by the expert when an
- // entry is created in the Name Registry.
- //
- //------------------------------------------------------
- USBDriverDescription TheUSBDriverDescription =
- {
- // Signature info
- kTheUSBDriverDescriptionSignature, // 'usbd'
- kInitialUSBDriverDescriptor, // 0
-
- // Device Info
- kDeviceVendorID, // USB Vendor ID
- kDeviceProductID, // USB Product ID.
- 0, // Release Number of Device
- 0, // Protocol Info.
-
- // Interface Info
- 0, // Configuration Value
- 0, // Interface Number
- kDeviceClass, // Interface Class
- kDeviceSubClass, // Interface SubClass
- 0, // Interface Protocol
-
- // Driver Info
- kDriverNameString, // Driver name for Name Registry
- kDeviceClass, // Device Class (from SampleStorageDeviceID.h)
- kDeviceSubClass, // Device Subclass
- kStorageHexMajorVers, kStorageHexMinorVers, kStorageReleaseStage, kStorageCurrentRelease, // version of driver = 0.0d0
-
- // Driver Loading Info
- kUSBDoNotMatchGenericDevice // Flags, Do not allow for generic match
- };
-
- USBClassDriverPluginDispatchTable TheClassDriverPluginDispatchTable =
- {
- kClassDriverPluginVersion, // Version of this structure
- StorageDriverValidateHW, // Hardware Validation Procedure
- StorageDriverInitDevice, // Initialization Procedure
- StorageDriverInitInterface, // Interface Initialization Procedure
- StorageDriverFinalize, // Finalization Procedure
- StorageDriverNotifyProc, // Driver Notification Procedure
- };
-
- // Hardware Validation
- // Called upon load by Expert
- OSStatus StorageDriverValidateHW ( USBDeviceRef device, USBDeviceDescriptorPtr pDesc )
- {
- #pragma unused ( device )
-
- if (IsThisASupportedProtocol( pDesc->protocol ) == false )
- {
- // This device speaks a protocol we do not understand, return back an error
- // so USB will try to find a better suited driver.
- return kUSBIncorrectTypeErr;
- }
-
- return noErr;
- }
-
-
- // Initialization function
- // Called upon load by Expert
- OSStatus StorageDriverInitDevice ( USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable )
- {
- busPowerAvailable = 0;
- StorageDriverEntry(device, pDesc, NULL );
-
- return noErr;
- }
-
- // StorageDriverInitInterface function
- // Called to initialize driver for an individual interface - either by expert or
- // internally by driver
- OSStatus StorageDriverInitInterface( UInt32 interfaceNum, USBInterfaceDescriptor *interfaceDesc,
- USBDeviceDescriptor *deviceDesc, USBDeviceRef device )
- {
- #pragma unused ( interfaceNum )
- if (IsThisASupportedProtocol( interfaceDesc->interfaceProtocol ) == false )
- {
- // This device speaks a protocol we do not understand, return back an error
- // so USB will try to find a better suited driver.
- return kUSBIncorrectTypeErr;
- }
-
- StorageDriverEntry(device, deviceDesc, interfaceDesc );
- return noErr;
- }
-
- // Termination function
- // Called by Expert when driver is being shut down
- OSStatus StorageDriverFinalize( USBDeviceRef device, USBDeviceDescriptorPtr desc )
- {
- #pragma unused( device, desc )
-
- StorageClassDriverFinalize();
-
- return noErr;
- }
-
- OSStatus StorageDriverNotifyProc( UInt32 notification, void* pointer, UInt32 refcon)
- {
- return StorageClassDriverNotifyProc(notification, pointer, refcon);
- }
-
-